package com.xlhj.boot.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author: liucaijing
 * @description: TopicListener
 * @date: 2021/10/20 9:05
 */
@Component
public class TopicListener {

    private static final String TOPIC_QUEUE_NAME_A = "topic-queue-A";
    private static final String TOPIC_QUEUE_NAME_B = "topic-queue-B";
    private static Logger logger = LoggerFactory.getLogger(TopicListener.class);

    @RabbitListener(queues = TOPIC_QUEUE_NAME_A)
    public void receiveMsgA(Message message) {
        String msg = new String(message.getBody());
        logger.info("接收到队列topic.queueA消息：{}", msg);
    }

    @RabbitListener(queues = TOPIC_QUEUE_NAME_B)
    public void receiveMsgB(Message message) {
        String msg = new String(message.getBody());
        logger.info("接收到队列topic.queueB消息：{}", msg);
    }
}
